<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: Calculation Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__profile__functions__calculation.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Calculation Functions<div class="ingroups"><a class="el" href="group__group__energy__profiler.html">Profile      (Energy Profiler)</a> &raquo; <a class="el" href="group__group__profile__functions.html">Functions</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gadeaf5617ad8fe9fa2cfb2c72e19bf488"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__calculation.html#gadeaf5617ad8fe9fa2cfb2c72e19bf488">Cy_Profile_GetRawCount</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ctrAddr, uint64_t *<a class="el" href="group__group__ipc__bt__data__structures.html#ga36692bbc61358ebc0e37a6fc6a395d28">result</a>)</td></tr>
<tr class="memdesc:gadeaf5617ad8fe9fa2cfb2c72e19bf488"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reports the raw count value for a specified counter.  <a href="#gadeaf5617ad8fe9fa2cfb2c72e19bf488">More...</a><br /></td></tr>
<tr class="separator:gadeaf5617ad8fe9fa2cfb2c72e19bf488"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2679f0e6dbd57afa6f5edff6721757ed"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__calculation.html#ga2679f0e6dbd57afa6f5edff6721757ed">Cy_Profile_GetWeightedCount</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ctrAddr, uint64_t *<a class="el" href="group__group__ipc__bt__data__structures.html#ga36692bbc61358ebc0e37a6fc6a395d28">result</a>)</td></tr>
<tr class="memdesc:ga2679f0e6dbd57afa6f5edff6721757ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reports the count value for a specified counter, multiplied by the weight factor for that counter.  <a href="#ga2679f0e6dbd57afa6f5edff6721757ed">More...</a><br /></td></tr>
<tr class="separator:ga2679f0e6dbd57afa6f5edff6721757ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf7064fd5a7d413a42fb9d3053cf8f8ea"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__profile__functions__calculation.html#gaf7064fd5a7d413a42fb9d3053cf8f8ea">Cy_Profile_GetSumWeightedCounts</a> (<a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a> ptrsArray[], uint32_t numCounters)</td></tr>
<tr class="memdesc:gaf7064fd5a7d413a42fb9d3053cf8f8ea"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reports the weighted sum result of the first n number of counter count values starting from the specified profile counter data structure base address.  <a href="#gaf7064fd5a7d413a42fb9d3053cf8f8ea">More...</a><br /></td></tr>
<tr class="separator:gaf7064fd5a7d413a42fb9d3053cf8f8ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="gadeaf5617ad8fe9fa2cfb2c72e19bf488"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadeaf5617ad8fe9fa2cfb2c72e19bf488">&#9670;&nbsp;</a></span>Cy_Profile_GetRawCount()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a> Cy_Profile_GetRawCount </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ctrAddr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint64_t *&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reports the raw count value for a specified counter. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctrAddr</td><td>The handle to the assigned counter, (returned by calling <a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a>).</td></tr>
    <tr><td class="paramname">result</td><td>Output parameter used to write in the result.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The raw count value of profile counter assigned to position #0</span></div><div class="line"><span class="comment">                 in the previous profiling window needs to be read. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Start the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Perform some activity... */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* When ready to read the results of the counter values, stop the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Variable for storing the raw count */</span></div><div class="line">    uint64_t rawCnt;</div><div class="line">    </div><div class="line">    <span class="comment">/* Get the raw count value of profile counter #0 */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__calculation.html#gadeaf5617ad8fe9fa2cfb2c72e19bf488">Cy_Profile_GetRawCount</a>(cntHandle[0], &amp;rawCnt))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">        </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga2679f0e6dbd57afa6f5edff6721757ed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2679f0e6dbd57afa6f5edff6721757ed">&#9670;&nbsp;</a></span>Cy_Profile_GetWeightedCount()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__profile__enums.html#ga7d980aa8f4c0159ccc47a973dd543e02">cy_en_profile_status_t</a> Cy_Profile_GetWeightedCount </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ctrAddr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint64_t *&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reports the count value for a specified counter, multiplied by the weight factor for that counter. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctrAddr</td><td>The handle to the assigned counter, (returned by calling <a class="el" href="group__group__profile__functions__counter.html#ga077b14aae89e02d6e01699e873fe3a9b">Cy_Profile_ConfigureCounter()</a>).</td></tr>
    <tr><td class="paramname">result</td><td>Output parameter used to write in the result.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The weighted count value of the profile counter assigned to </span></div><div class="line"><span class="comment">                 position #0 in the previous profiling window needs to be read. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Start the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* When ready to read the results of the counter values, stop the profiling window. */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Variable for storing the weighted count */</span></div><div class="line">    uint64_t weightedCnt;</div><div class="line">    </div><div class="line">    <span class="comment">/* Get the weighted count value of profile counter #0 */</span></div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="group__group__profile__enums.html#gga7d980aa8f4c0159ccc47a973dd543e02a9328da8e423851a200dc18bceea5b54c">CY_PROFILE_SUCCESS</a> != <a class="code" href="group__group__profile__functions__calculation.html#ga2679f0e6dbd57afa6f5edff6721757ed">Cy_Profile_GetWeightedCount</a>(cntHandle[0], &amp;weightedCnt))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Insert error handling */</span></div><div class="line">    }</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="gaf7064fd5a7d413a42fb9d3053cf8f8ea"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf7064fd5a7d413a42fb9d3053cf8f8ea">&#9670;&nbsp;</a></span>Cy_Profile_GetSumWeightedCounts()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t Cy_Profile_GetSumWeightedCounts </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__profile__data__structures.html#gac954b1f2e2b8fc00b15f89c0b1fe372e">cy_stc_profile_ctr_ptr_t</a>&#160;</td>
          <td class="paramname"><em>ptrsArray</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>numCounters</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reports the weighted sum result of the first n number of counter count values starting from the specified profile counter data structure base address. </p>
<p>Each count value is multiplied by its weighing factor before the summing operation is performed.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptrsArray</td><td>Base address of the profile counter data structure</td></tr>
    <tr><td class="paramname">numCounters</td><td>Number of measured counters in ptrsArray[]</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The weighted sum of the specified counters</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line"></div><div class="line">    <span class="comment">/* Scenario: The weighted average of assigned profile counters in positions</span></div><div class="line"><span class="comment">                 #0 to #5 in the previous profiling window needs to be read. */</span></div><div class="line">    </div><div class="line">    <span class="comment">/* List of handles for allocated counters */</span></div><div class="line">    <a class="code" href="structcy__stc__profile__ctr__t.html">cy_stc_profile_ctr_ptr_t</a> cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};</div><div class="line">    </div><div class="line">    <span class="comment">/* Start the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#gad8b4c8660845665052ffc891d9b1cd50">Cy_Profile_StartProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* When ready to read the results of the counter values, stop the profiling window */</span></div><div class="line">    <a class="code" href="group__group__profile__functions__general.html#ga4a4a1151a6c68338ab316b8119ae91ec">Cy_Profile_StopProfiling</a>();</div><div class="line">    </div><div class="line">    <span class="comment">/* Energy limit (example) of a profiling window */</span></div><div class="line">    uint64_t energyLimit =  0x00020000UL;</div><div class="line">    </div><div class="line">    <span class="comment">/* Get the weighted average of assigned profile counters in positions #0 to #5 */</span></div><div class="line">    uint64_t weightedAvg = <a class="code" href="group__group__profile__functions__calculation.html#gaf7064fd5a7d413a42fb9d3053cf8f8ea">Cy_Profile_GetSumWeightedCounts</a>(&amp;cntHandle[0], 6UL);</div><div class="line">    </div><div class="line">    <span class="keywordflow">if</span>(weightedAvg &gt; energyLimit)</div><div class="line">    {</div><div class="line">        <span class="comment">/* The energy consumption is more than expected for this profiling window.</span></div><div class="line"><span class="comment">           Take appropriate measures to reduce the energy consumption. */</span></div><div class="line">    }</div><div class="line">    </div></div><!-- fragment --></dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
